package com.jiepos.mpos.biz.code.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.code.service.SuperBankService;
import com.jiepos.mpos.common.entity.App_Inf_SuperbankEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 * 
 * 总行号管理
 * @ProjectName:  [mpos] 
 * @Package com.jiepos.mpos.biz.code.controller 
 * @author 张磊
 * @version 1.0
 * @since 2017年10月13日 上午11:51:01
 * @history（历次修订内容、修订人、修订时间等）
 * @UpdateRemark [说明本次修改内容]
 * @Copyright (c) 2017 江苏杰博实信息技术有限公司
 */
@Controller
@RequestMapping("superbank")
public class SuperBankController extends BaseController {

	@Autowired
	private SuperBankService superBankService;
	
	/**
	 * 进入总行行号列表页
	 * @param request
	 * @param response
	 * @param pagination
	 * @return
	 */
	@RequestMapping("/getSuperBankList.do")
	public ModelAndView getSuperBankList(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination) {
		ModelAndView model = new ModelAndView("/module/code/superbank/superbank_list");		
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 获取总行行号列表Json数据
	 * @param request
	 * @param response
	 * @param pagination
	 * @param appInfSuperbankEntity
	 * @return
	 */
	@RequestMapping("/getSuperBankListJson.do")
	@ResponseBody
	public Map getSuperBankListJson(HttpServletRequest request, HttpServletResponse response,
			Pagination pagination, App_Inf_SuperbankEntity appInfSuperbankEntity){
		
		return superBankService.getSuperBankList(pagination,appInfSuperbankEntity);
	}
	
	/**
	 * 获取总行行号详情
	 * @param request
	 * @param response
	 * @param super_bank_uuid
	 * @return
	 */
	@RequestMapping("/getSuperBankDetail.do")
	public ModelAndView getSuperBankDetail(HttpServletRequest request, HttpServletResponse response,String super_bank_uuid){
		ModelAndView model = new ModelAndView("/module/code/superbank/superbank_detail");
		App_Inf_SuperbankEntity app_Inf_SuperbankEntity = superBankService.getSuperBankById(super_bank_uuid);
		model.addObject("appInfSuperbankEntity", app_Inf_SuperbankEntity);
		return super.getDetail(request, response, model);
	}
	
	/**
	 * 验证总行行号的唯一性
	 * @param request
	 * @param response
	 * @param app_Inf_SuperbankEntity
	 * @return
	 */
	@RequestMapping("/checkSuperbank.do")
	@ResponseBody
	public String checkSuperbank(HttpServletRequest request, HttpServletResponse response,App_Inf_SuperbankEntity app_Inf_SuperbankEntity){
		return superBankService.checkSuperbank(app_Inf_SuperbankEntity);
	}
	
	/**
	 * 保存总行行号信息
	 * @param request
	 * @param response
	 * @param app_Inf_SuperbankEntity
	 * @return
	 */
	@RequestMapping("/saveSuperbank.do")
	public ModelAndView saveSuperbank(HttpServletRequest request, HttpServletResponse response,App_Inf_SuperbankEntity app_Inf_SuperbankEntity){
		Map map=super.getLoginUser(request, response);
		superBankService.saveSuperBank(app_Inf_SuperbankEntity,map);
		return new ModelAndView(new RedirectView("getSuperBankList.do"),map);
	}
	
	@RequestMapping("/deleteSuperBankByIds.do")
	public ModelAndView deleteSuperBankByIds(HttpServletRequest request, HttpServletResponse response,String super_bank_uuids){
		superBankService.deleteSuperBankByIds(super_bank_uuids);
		Map map=super.getLoginUser(request, response);
		return new ModelAndView(new RedirectView("getSuperBankList.do"),map);
	}
	
}
